<!DOCTYPE html>
<html lang="en">
<head>
    <title>新增需求</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_855021_df13d5353cs.css">
    <link rel="stylesheet" href="/dist/plugins/webuploader-0.1.5/webuploader.css">
    
    <style>
        textarea{
            padding: 0;
        }
        .webuploader-pick {
            background: url(/dist/img/fjT1.png) no-repeat 5px center;
            display: block;
            padding: 0 4px;
            height: 22px;
            line-height: 22px;
            padding-left: 15px;
            margin: 0 auto;
            width: 70px;
            border-radius: 4px;
            color: #2a8cec;
        }
        .webuploader-pick-hover {
            color: #fff !important;
            background: url(/dist/img/fjT2.png) no-repeat 5px center;
            background-color: #0F6099;

        }
        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .tdColor {
            width:190px;
            background-color: #f8f8f8;
        }

        .tdColor .icon-ren,.tdColor .icon-ren3{
            position: absolute;
            font-size: 16px;
        }
        .tdColor .icon-bixutian{
            font-size: 12px;
            color: red;
        }

        .td-value {
            text-align: left !important;
            vertical-align: middle;
            word-wrap: break-word;
            color: #2a8cec !important;
        }

        .td-value span {
            display: inline-block;
            max-height: 56px;
            overflow: hidden;
            padding: 0 6px;
            word-wrap: break-word;
            text-align: center !important;
        }
        .td-value1 {
            text-align: left !important;
            vertical-align: middle;
            word-wrap: break-word;
            color: #2a8cec !important;
        }
        .td-value1 .user{
            display: inline-block;
            float: left;
            overflow: hidden;
            cursor: pointer;
        }
        .user.select{
            color: #fff;
            background-color: #045B9E;
        }
        .td-value1 input,textarea{
            width: 100%;
            border: 0;
            outline: none;
        }
        .zt .td-value1{
            text-align: center !important;
        }
        .weChat{
            position: absolute;
            left: 200px;
            margin-top: 2px;
        }
        .weChat input{
            position: absolute;
            bottom: 18px;
            left: -15px;
        }

        .head td,.track-title{
            background-color: yellow;
            text-align: center;
        }

        .t-center input,.t-center{
            text-align: center !important; 
        }
        .table>thead>tr>th{
            background:#d3e8fd !important;
        }
        select {
            text-align: center;
            text-align-last: center;
            width: 100%;
            border: 0
        }
        
    </style>
</head>
<body>
<iframe id="ifAttach" style="display:none"></iframe>
<section class="content" id="app" style="width: 650px;margin: 0 auto">
    <!-- <div class="tableTitle" style="text-align: center;font-weight: bold;font-size: 20px">进度跟踪</div> -->
    <table class="table table-bordered text-center table-width" style="margin-bottom:-1px;">
        <tbody>
            <tr>
                <td class="tdColor">任务描述</td>
                <td class="td-value1">
                    {{mainInfo.proName}}
                </td>
            </tr>
            <tr>
                <td class="tdColor">今日进度描述</td>
                <td class="td-value1">
                    <textarea rows="4" style="resize: none" v-if='isFZR' v-model="mainInfo.trackContent"></textarea>
                    <textarea rows="4" style="resize: none" v-if='!isFZR' readonly v-model="mainInfo.trackContent"></textarea>
                </td>
            </tr>
            <tr>
                <td class="tdColor">
                    <span v-if="!isFZR">附件</span>
                    <div  v-if="isFZR" id="divUpload" >添加附件</div>
                </td>
                <td class="td-value1">
                    <div v-for="(attach,i) in attaches" class="fj-tanzhongStyle">
                        <b :class="fjStyle(attach.name)"></b>
                        <div class="name" v-if="attach.name" :title="attach.name">
                            {{attach.name}}
                        </div>
                        <div class="down">
                            <a href="javascript:void(0)" class="nui-txt-link" @click="download(attach.url,attach.name)">下载</a>
                        </div>
                        <div class="del" v-if="isFZR">
                            <a href="javascript:void(0)" class="nui-txt-link" @click="deleteFile(i)">删除</a>
                        </div>
                        <!--<div class="info"><span class="nui-txt-suc">上传完成</span></div>-->
                    </div>
                </td>
            </tr>
            <tr class="zt">
                <td class="tdColor">状态</td>
                <td class="td-value1" v-if='isFZR && (mainInfo.status==1||mainInfo.status==2||mainInfo.status==4||mainInfo.status==6)'>
                    <select v-model="mainInfo.status" >
                        <option v-if="mainInfo.proLevel==2 && status!=6" value="2">进行中</option>
                        <option v-if="mainInfo.proLevel==3 && status!=6" value="2">进行中</option>
                        <option v-if="status==6" value="6">已逾期</option>
                        <option value="4">已完成-待审核</option>
                    </select>
                </td>
                <td class="td-value1" v-if='isFZR && (mainInfo.status==5||mainInfo.status==3)'>
                    <span v-if="mainInfo.status==1">未开始</span>
                    <span v-if="mainInfo.status==2">进行中</span>
                    <span v-if="mainInfo.status==3">完成</span>
                    <span v-if="mainInfo.status==4">已完成-待审核</span>
                    <span v-if="mainInfo.status==5">已撤销</span>
                    <span v-if="mainInfo.status==6">已逾期</span>
                </td>
                <td class="td-value1" v-if='!isFZR'>
                    <span v-if="mainInfo.status==1">未开始</span>
                    <span v-if="mainInfo.status==2">进行中</span>
                    <span v-if="mainInfo.status==3">完成</span>
                    <span v-if="mainInfo.status==4">已完成-待审核</span>
                    <span v-if="mainInfo.status==5">已撤销</span>
                    <span v-if="mainInfo.status==6">已逾期</span>
                </td>
            </tr>
        </tbody>
    </table>

    <div class="track-title tableTitle" style="height:30px;line-height:30px;border:1px solid #cdcdcd;border-bottom:0;">跟踪记录</div>
    <table class="table table-bordered text-center table-width">
        <tbody>
            <tr v-if="childTrackList.length==0">
                <td style="font-size:20px;font-weight: bold;">暂无跟踪记录</td>
            </tr>
            <tr v-else>
                <td class="tdColor">跟踪人员</th>
                <td class="tdColor">跟踪时间</th>
                <td class="tdColor">跟踪内容</th>
            </tr>
            <template v-for="(item,i) in childTrackList">
                <tr>
                    <td class="td-value1 t-center">
                        {{item.userName}}
                    </td>
                    <td class="td-value1 t-center">
                        {{item.trackDate}}
                    </td>
                    <td class="td-value1 " style="text-align:center;">
                        {{item.trackContent}}
                    </td>
                </tr>
            </template>
        </tbody>
    </table>
    
    <div class="south" style="height:50px;line-height:50px;text-align:center;">
        <input type="button" v-if="isFZR && (status==1 || status==2 || status==4|| status==6 )" value="保存" class="btn oaBtn btn-sm" @click="saveInfo()"/>
        <input type="button" v-if="(authorityList.cpLeader && mainInfo.proLevel==2 && status==4) || (authorityList.kfLeader && mainInfo.proLevel==3 && status==4)" value="通过" class="btn oaBtn btn-sm" @click="updateProStatus(3)"/>
        <input type="button" v-if="(authorityList.cpLeader && mainInfo.proLevel==2 && status==4) || (authorityList.kfLeader && mainInfo.proLevel==3 && status==4)"  value="驳回" class="btn oaBtn btn-sm" @click="updateProStatus(2)"/>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script src="/dist/plugins/webuploader-0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="/dist/js/pages/common/commonService.js"></script>
<script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var app = new Vue({
        el: '#app',
        data: {
            pageType:"add",
            userId:getCurrentUser().id,
            isFZR:true,
            mainInfo:{createUserId:getCurrentUser().id,trackContent:"",statusChanged:false},
            childTrackList:[],
            authorityList:{cpLeader:false,kfLeader:false},
            status:"",
            statusChanged:false,
            isKfLeader:0, //1:是;0:否
            attaches:[]
        },
        methods: {
            getInfoById:function(){
                var that = this;
                $.wyui.postMethod(urlConfig.system.rightOp.getRightOpByUserId, {userId: that.userId}, function (data) {
                    for (var i = 0; i < data.length; i++) {
                        that.authorityList[data[i].eName] = true;
                    }
                },true);
                that.authorityList.kfLeader = that.isKfLeader==1?true:false;

                $.wyui.postMethod(urlConfig.pm.projectTrack.getProTrackInfoByParentId, {
                    "projectId":that.projectId
                }, function (data) {
                    that.childTrackList = data.childTrackList;
                    that.mainInfo = data.info;
                    that.status = data.info.status;
                    that.mainInfo.createUserId = getCurrentUser().id;
                    if(data.info.proPrincipal == that.userId){
                        that.isFZR = true;
                        that.mainInfo.status = that.status=="1"?"2":that.status;
                    }else
                        that.isFZR = false;
                },true);

                $.wyui.postMethod(urlConfig.pm.projectTrack.getProjectAttaches, {
                    id:that.mainInfo.projectId
                }, function (data) {
                   that.attaches = data.attaches;
                });

               
            },
            saveInfo:function(){
                var that = this;
                if(that.status !=that.mainInfo.status)
                    that.mainInfo.statusChanged = true;
                else
                    that.mainInfo.statusChanged = false;
                that.mainInfo.attaches = that.attaches;
                $.wyui.postMethod(urlConfig.pm.projectTrack.saveProjectTrack, that.mainInfo, function (data) {
                    parent.refresh();
                    api.close();
                    // that.getInfoById();
                });
            },
            updateProStatus:function(type){
                var that = this;
                
                $.wyui.postMethod(urlConfig.pm.projectTrack.updateProStatus, {
                    projectId:that.mainInfo.projectId,
                    status:type,
                    senderName:getCurrentUser().name
                }, function (data) {
                    parent.refresh();
                    api.close();
                    // that.getInfoById();
                });
            },
            showDatePicker: function (e, type) {
                var that =this;
                WdatePicker({
                    onpicked: function (dp) {
                        if(type == 'startTime')
                            that.startTime = dp.cal.getNewDateStr();
                        else
                            that.endTime = dp.cal.getNewDateStr();
                        return true;
                    }
                });
                $(e.target).blur();
            },
            download: function (attachId, fileName) {
                downloadFile(attachId,fileName)
                return false;
            },
            deleteFile: function (i) {
                if (window.confirm("确定要删除该附件吗?")) {
                    this.attaches.splice(i, 1);
                }
            },
            fjStyle: function (fjName) {
                if (fjName) {
                    var type = fjName.substring(fjName.lastIndexOf('.') + 1);
                    return 'img fj-' + type
                }
                return 'img'
            },
            initUpload:function(){
                var that = this;
                this.uploader = WebUploader.create({
                    // 选完文件后，是否自动上传。
                    auto: true,
                    // swf文件路径
                    swf: "/statics/plugin/webuploader-0.1.5/Uploader.swf",
                    // 文件接收服务端。
                    server: server.ip +"/attach/uploadFile.json",
                    // 选择文件的按钮。可选。
                    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                    pick: '#divUpload',
                    duplicate: true
                });
                this.uploader.on("uploadStart", function () {
                    $("#progress").show();
                });
                this.uploader.on("uploadComplete", function () {
                    $("#progress").hide();
                });
                // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                this.uploader.on('uploadSuccess', function (file, response) {
                    if (response._raw == "文件上传出错！") {
                        alert("文件上传出错！");
                    } else {
                        that.attaches.push({
                            id: response.id,
                            name: response.name,
                            url: response.url
                        });
                    }
                });
                // 文件上传失败，显示上传出错。
                this.uploader.on('uploadError', function (file) {
                    alert("上传失败！");
                });
            }
        },
        mounted: function () {
            // this.pageType = $.wyui.page.urlParams.pageType;
            this.projectId = $.wyui.page.urlParams.projectId;
            this.isKfLeader = $.wyui.page.urlParams.isKfLeader;

            this.getInfoById();
            this.initUpload();
        }
    });
</script>
<script>
    $(function(){
        $(".proPrincipal").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                for (var i = 0; i < users.length; i++) {
                    $("<li></li>").data("autoComplete",
                        users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (user) {
                var selectIndex = app.taskSelectedIndex;
                app.taskList[selectIndex].proPrincipal = user.id;
                app.taskList[selectIndex].proPrincipalName = user.name;
                // $(this).val("");
                return false;
            },
            height: 180,
            width: 300
        });

    });
</script>

</body>
</html>